<?php

/**
 * Site form base class.
 *
 * @method Site getObject() Returns the current form's model object
 *
 * @package    Web20
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseSiteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                  => new sfWidgetFormInputHidden(),
      'name'                => new sfWidgetFormInputText(),
      'description'         => new sfWidgetFormInputText(),
      'logo'                => new sfWidgetFormInputText(),
      'payment_enabled'     => new sfWidgetFormInputCheckbox(),
      'dineromail_store_id' => new sfWidgetFormInputText(),
      'background_image'    => new sfWidgetFormInputText(),
      'color_1'             => new sfWidgetFormInputText(),
      'color_2'             => new sfWidgetFormInputText(),
      'color_3'             => new sfWidgetFormInputText(),
      'location'            => new sfWidgetFormInputText(),
      'font'                => new sfWidgetFormInputText(),
      'user_id'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => true)),
      'category_id'         => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'add_empty' => true)),
      'slug'                => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'                  => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'name'                => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'description' => new sfValidatorPass(array('required' => false)),
      'logo'                => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'payment_enabled'     => new sfValidatorBoolean(array('required' => false)),
      'dineromail_store_id' => new sfValidatorInteger(array('required' => false)),
      'background_image'    => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'color_1'             => new sfValidatorString(array('max_length' => 7, 'required' => false)),
      'color_2'             => new sfValidatorString(array('max_length' => 7, 'required' => false)),
      'color_3'             => new sfValidatorString(array('max_length' => 7, 'required' => false)),
      'location'            => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'font'                => new sfValidatorString(array('max_length' => 50, 'required' => false)),
      'user_id'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'required' => false)),
      'category_id'         => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Category'), 'required' => false)),
      'slug'                => new sfValidatorString(array('max_length' => 255, 'required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'Site', 'column' => array('slug')))
    );

    $this->widgetSchema->setNameFormat('site[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Site';
  }

}
